Fix stale PR file fetch completion#12
Conversation
|
Addressed: added prebuild: npm test so the existing Build workflow runs the regression tests before nest build. Local npm run build, npm run lint, and npm run format:check pass. |
|
To clarify the prior "no tests" — this repo doesn't accept tests in contributor PRs. Drop |
updated |
anderdc
left a comment
There was a problem hiding this comment.
Slim this down. The unique jobId change solves the actual dedup bug; the row-lock and the generation re-checks scattered through the fetch path defend against a rarer concurrent-job interleave whose worst case is a few seconds of mixed file rows that the re-enqueue path heals on its own.
Keep:
prFilesJobIdhelper inpackages/das/src/queue/constants.tsand theexpectedHeadSha/expectedBaseShathreading throughpull-request.handler.ts,fetch.processor.ts, and the backfill enqueue.- The head/base WHERE-clause guard on the final
scoringDataStored=trueupdate infetch.processor.ts(prGenerationCriteria). handleStalePrFilesJobre-enqueue when the guarded update reportsaffected=0.
Drop:
writeIfCurrentPrFilesGenerationand thepessimistic_writetransaction wrapper ingithub-fetcher.service.ts.- The
isCurrentPrFilesGenerationchecks sprinkled throughfetchAndStorePrFilesandfetchAndStoreBatchedContents. - The contents-batching refactor — revert to the per-file
upsertinside the loop.
Net result should be ~30 lines instead of ~330, same fix for the documented bug.
|
done |
|
@anderdc please close my PR. |
Summary
Prevent stale active
fetch-pr-filesjobs from marking newer PR generations complete.This change ties PR file-fetch jobs to the expected
headSha/baseSha, uses those values in the BullMQ job id, and only marksscoringDataStored=truewhen the current PR row still matches the job generation. If the final guarded update finds that its generation is stale, it clears the trusted completion flag and enqueues a current-generation fetch.Related Issues
Closes #11
Type of Change
Testing
npm run format:checknpm run lintnpm run buildgit diff --checkChecklist